home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Cinemovies (FR).ifs < prev    next >
Text File  |  2005-05-23  |  19KB  |  545 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=ScorEpioN
  8. Title=Cinemovies.fr
  9. Description=Le magazine du cinΘma international
  10. Site=http://www.cinemovies.fr
  11. Language=FR
  12. Version=04 du 23/05/2005
  13. Requires=3.5
  14. Comments=Ce script nΘcessite le fichier ScorEpioNCommonScript.pas|.==.| :   ' ( ( ( ( /\ |  "==()))))):     ⌐ ScorEpioN ⌐|       ( ( ( ( \_/
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. Mise α jour=1|1|0=Oui|1=Non
  20. Type de Lancement=0|0|0=Demande le titre avant de lancer le script|1=Ne demande pas le titre avant de lancer le script|2=Cherche le meilleur rΘsultat sans confirmation|3=Lancement automatique sur l'adresse web
  21. Casse Choisie=3|3|0=Titre et Nom en minuscule|1=Titre et Nom en majuscule|2=PremiΦre lettre en majuscule|3=PremiΦre lettre de chaque mot en majuscule
  22. Titre en double=0|0|0=Garde les titres originaux et traduits mΩme identiques|1=Garde les titres originaux si identiques|2=Garde les titres traduits si identiques
  23. Recherche sur le titre=0|0|0=Traduit|1=Original
  24. Choix Image=1|1|0=Petite affiche|1=Grande affiche
  25. Fichier de log=1|1|0=Oui|1=Non
  26.  
  27. ***************************************************)
  28.  
  29. program Cinemovies_FR;
  30. uses
  31.   ScorEpioNCommonScript;
  32.  
  33. const
  34.      VersionScript = '04 du 23/05/2005';
  35.      NomScript = 'CINEMOVIES';
  36.      urlDomain = 'cinemovies.fr';
  37.      cinemovies = 'http://www.cinemovies.fr/';
  38.      cinemoviesSearch = cinemovies+'resultat_recherche.php?cherche=';
  39.      cinemoviesSubmit = '&x=0&y=0';
  40.      cinemoviesFiche = 'fiche_film.php?IDfilm=';
  41.      cinemoviesPhoto = 'fiche_photos.php?IDfilm=';
  42.      cinemoviesAffiche = 'fiche_affiches.php?IDfilm=';
  43.      timeSleep = 500;
  44. var
  45.   MovieName, Address, ID : string;
  46.   i, premiereExecution : Integer;
  47.   listeResultat: TStringList;
  48.  
  49. //------------------------------------------------------------------------------
  50. // RECUPERE LES RESULTATS CINEMOVIES.FR
  51. //------------------------------------------------------------------------------
  52.  
  53. procedure recherche(title : String);
  54. var
  55.   adresseRecherche, Line, annee, complement, titre, adresse : String;
  56.   StartPos, EndPos : Integer;
  57. begin
  58.   adresseRecherche := cinemoviesSearch+UrlEncode(title)+cinemoviesSubmit;
  59.   Line := GetPage(adresseRecherche);
  60.   if pos('Films</td>', Line) > 0 then
  61.   begin
  62.     listeResultat := TStringList.Create;
  63.     StartPos := pos('Films</td>', Line);
  64.     delete(Line, 1, StartPos+length('Films</td>')-1);
  65. // Films dΘjα sortis
  66.     if pos('Films dΘjα sortis:', Line) > 0 then
  67.     begin
  68.       StartPos := pos('Films dΘjα sortis:', Line);
  69.       delete(Line, 1, StartPos+length('Films dΘjα sortis:')-1);
  70.       StartPos := pos('<a href="', Line);
  71.       delete(Line, 1, StartPos-1);
  72.       repeat
  73.        StartPos := pos('<a href="', Line);
  74.        delete(Line, 1, StartPos-1);
  75.        adresse := cinemovies+findInfo('<a href="', '"', Line,'0');
  76.        titre := findInfo('arial12black3">', '<font color="#000080">', Line,'0');
  77.        annee := findInfo('<font color="#000080">', '</font>', Line,'0');
  78.        annee := StringReplace(annee, '(', '');
  79.        annee := StringReplace(annee, ')', '');
  80.        annee := Trim(annee);
  81.        complement := findInfo('</font><br>', '<br>', Line,'0');
  82.        complement := StringReplace(complement, ' ', '');
  83. // Ajoute les films
  84.        listeResultat.Add(annee+'|'+titre+'|'+adresse+'|'+complement);
  85.        delete(Line, 1, length('<a href="'));
  86.        EndPos := pos('nav_arrow231.gif', Line);
  87.        StartPos := pos('<a href="', Line);
  88.       until (StartPos > EndPos);
  89.     end;
  90.  
  91. // Films bient⌠t en salles
  92.     if pos('Films bient⌠t en salles:', Line) > 0 then
  93.     begin
  94.       StartPos := pos('Films bient⌠t en salles:', Line);
  95.       delete(Line, 1, StartPos+length('Films bient⌠t en salles:')-1);
  96.       StartPos := pos('<a href="', Line);
  97.       delete(Line, 1, StartPos-1);
  98.       repeat
  99.        StartPos := pos('<a href="', Line);
  100.        delete(Line, 1, StartPos-1);
  101.        adresse := cinemovies+findInfo('<a href="', '"', Line,'0');
  102.        titre := findInfo('arial12black3">', '<font color="#000080">', Line,'0');
  103.        annee := findInfo('<font color="#000080">', '</font>', Line,'0');
  104.        annee := StringReplace(annee, '(', '');
  105.        annee := StringReplace(annee, ')', '');
  106.        annee := Trim(annee);
  107.        complement := findInfo('</font><br>', '<br>', Line,'0');
  108.        complement := StringReplace(complement, ' ', '');
  109. // Ajoute les films
  110.        listeResultat.Add(annee+'|'+titre+'|'+adresse+'|'+complement);
  111.        delete(Line, 1, length('<a href="'));
  112.        EndPos := pos('nav_arrow231.gif', Line);
  113.        StartPos := pos('<a href="', Line);
  114.       until (StartPos > EndPos);
  115.     end;
  116.  
  117. // CrΘation de la liste de rΘsultats
  118.     afficheResultat(title);
  119.   end else
  120.   begin
  121.     SetField(fieldChecked, '');
  122.     exit;
  123.   end;
  124. end;
  125.  
  126. //------------------------------------------------------------------------------
  127. // CREATION DE LA LISTE DE RESULTAT
  128. //------------------------------------------------------------------------------
  129.  
  130. procedure afficheResultat(title : String);
  131. var
  132.    StartPos: Integer;
  133.    couple, annee, complement, titre, adresse : String;
  134. begin
  135.  
  136.   if (GetOption('Type de Lancement') = 0) or (GetOption('Type de Lancement') = 1) then
  137.   begin
  138.    PickTreeClear;
  139.    PickTreeAdd('Films trouvΘs pour ' + title + ' :', '');
  140.    for i:=0 to listeResultat.Count-1 do
  141.    begin
  142.      couple := listeResultat.GetString(i);
  143.      annee := copy(couple,0,pos('|',couple)-1);
  144.      delete(couple, 1, length(annee)+1);
  145.      titre := copy(couple,0,pos('|',couple)-1);
  146.      delete(couple, 1, length(titre)+1);
  147.      HTMLDecode(titre);
  148.      adresse := copy(couple,0,pos('|',couple)-1);
  149.      delete(couple, 1, length(adresse)+1);
  150.      complement := copy(couple,0,length(couple));
  151.      delete(couple, 1, length(complement)+1);
  152.      PickTreeAdd('['+annee+'] '+titre+' '+complement, adresse);
  153.    end;
  154.  
  155.    if listeResultat.Count = 1 then
  156.    begin
  157.      recupInfo(adresse);
  158.      exit;
  159.    end;
  160.  
  161.     begin
  162.       if PickTreeExec(Address)=true then
  163.       begin
  164.           recupInfo(Address);
  165.       end;
  166.     end;
  167.   end else if (GetOption('Type de Lancement') = 2) then
  168.   begin
  169.    if listeResultat.Count = 1 then
  170.    begin
  171.      couple := listeResultat.GetString(0);
  172.      annee := copy(couple,0,pos('|',couple)-1);
  173.      delete(couple, 1, length(annee)+1);
  174.      titre := copy(couple,0,pos('|',couple)-1);
  175.      delete(couple, 1, length(titre)+1);
  176.      HTMLDecode(titre);
  177.      adresse := copy(couple,0,pos('|',couple)-1);
  178.      recupInfo(adresse);
  179.      exit;
  180.    end else
  181.    begin
  182.      trouveTitle(title);
  183.    end;
  184.   end;
  185. end;
  186.  
  187. //------------------------------------------------------------------------------
  188. // RECUPERE LES INFOS
  189. //------------------------------------------------------------------------------
  190.  
  191. procedure recupInfo(Adresse : String);
  192. var
  193.    Value, Value2, Line: String;
  194.    StartPos : Integer;
  195. begin
  196. // Pour le mode Batch
  197.    if (GetOption('Fichier de log') = 0) then
  198.      beforeUpdate();
  199. // DΘbut du script de rΘcupΘration
  200.    ID := StringReplace(Adresse, cinemovies+cinemoviesFiche, '');
  201.    Line := GetPage(Adresse);
  202. // Jaquette DVD
  203.    if CanSetPicture then
  204.      recupImage(Line);
  205. // Titre Traduit
  206.    if CanSetField(fieldTranslatedTitle) then
  207.      MonSetField(fieldTranslatedTitle, formatTitre(findInfo('<TD class="arial12blacknews">', ' :</TD>', Line,'0'),GetOption('Casse Choisie')));
  208. // AnnΘe
  209.    if CanSetField(fieldYear) then
  210.       MonSetField(fieldYear, nettoieAnnee(findInfo('<b>Sortie(s)</b>:', '</b>', Line,'0')));
  211. // Genre
  212.    if CanSetField(fieldCategory) then
  213.    begin
  214.       Value := formatTitre(findInfo('Genre:', '<img', Line,'0'),GetOption('Casse Choisie'));
  215.       Value := StringReplace(Value, ',', ', ');
  216.       MonSetField(fieldCategory, deleteEnd(Value, ', '));
  217.    end;
  218. // DurΘe
  219.    if CanSetField(fieldLength) then
  220.       MonSetField(fieldLength, DureeEnMinutes(findInfo('DurΘe: ', '</td>', Line,'0')));
  221. // RΘalisateur
  222.    if CanSetField(fieldDirector) then
  223.    begin
  224.       Value := formatTitre(findInfo('RΘalisΘ par:</b></td>', '</td>', Line,'0'),GetOption('Casse Choisie'));
  225.       Value := StringReplace(Value, ',', ', ');
  226.       MonSetField(fieldDirector, deleteEnd(Value, ', '));
  227.    end;
  228. // Acteurs
  229.    if CanSetField(fieldActors) then
  230.    begin
  231.       Value := formatTitre(findInfo('Avec:</b></td>', '</td>', Line,'0'),GetOption('Casse Choisie'));
  232.       Value := StringReplace(Value, ',', ', ');
  233.       MonSetField(fieldActors, deleteEnd(Value, ', ')+'.');
  234.    end;
  235. // L'histoire
  236.    if CanSetField(fieldDescription) then
  237.          MonSetField(fieldDescription,findInfo('arial11blacknews">L''histoire</font></td>', '</td>', Line,'0'));
  238. // Pays
  239.    if CanSetField(fieldCountry) then
  240.       MonSetField(fieldCountry, findInfo('Pays</b></td>', '</td>', Line,'0'));
  241. // ScΘnario
  242.    if CanSetField(fieldProducer) then
  243.       begin
  244.       Value := formatTitre(findInfo('ScΘnario</b></td>', '</td>', Line,'0'),GetOption('Casse Choisie'));
  245.       Value := StringReplace(Value, ',', ', ');
  246.       MonSetField(fieldProducer, deleteEnd(Value, ', '));
  247.    end;
  248. // Titre Original
  249.    if CanSetField(fieldOriginalTitle) then
  250.       MonSetField(fieldOriginalTitle, formatTitre(findInfo('Titre original</b></td>', '</td>', Line,'0'),GetOption('Casse Choisie')));
  251. // Note Moyenne
  252.    if CanSetField(fieldRating) then
  253.    begin
  254.       Value := findInfo('<font size="5">', '/5', Line,'0');
  255.       delete(Line, 1, pos('/5',Line));
  256.       Value2 := findInfo('<font size="5">', '/5', Line,'0');
  257.       MonSetField(fieldRating, moyenne(Value, Value2));
  258.    end;
  259. // Adresse Web
  260.   if CanSetField(fieldURL) then
  261.       SetField(fieldURL, Adresse);
  262.  
  263. // Pour le mode Batch
  264.   if (GetOption('Fichier de log') = 0) then
  265.     afterUpdate();
  266.  
  267. // Affichage des titres si original et traduit identique
  268.   titreDouble(GetOption('Titre en double'));
  269.  
  270. end;
  271.  
  272. //------------------------------------------------------------------------------
  273. // RECUPERE L'AFFICHE
  274. //------------------------------------------------------------------------------
  275.  
  276. procedure recupImage(Line : String);
  277. var
  278.    adresse, adresseAutre : String;
  279. begin
  280.      if (pos(cinemoviesPhoto+ID,Line) <> 0) then
  281.      begin
  282.        Sleep(timeSleep);
  283.        Line := GetPage(cinemovies+cinemoviesPhoto+ID);
  284.        if (pos(cinemoviesAffiche+ID,Line) <> 0) then
  285.        begin
  286.          Sleep(timeSleep);
  287.          Line := GetPage(cinemovies+cinemoviesAffiche+ID);
  288.          adresse := cinemovies+'images/data/affiches/'+findInfo('images/data/affiches/', '"', Line,'0');
  289.          delete(Line,1,pos('images/data/affiches/',Line)+length('images/data/affiches/'));
  290.          if pos('images/data/affiches/', Line) <> 0 then
  291.          begin
  292.            adresseAutre := cinemovies+'images/data/affiches/'+findInfo('images/data/affiches/', '"', Line,'0');
  293.            adresse := adresseAutre;
  294.          end;
  295.          if (GetOption('Choix Image') = 1) then
  296.          begin
  297.            adresse := StringReplace(adresse, 'Paff', 'Gaff');
  298.            adresse := StringReplace(adresse, 'AFFP', 'AFFG');
  299.          end;
  300.          GetPicture(adresse);
  301.        end;
  302.      end;
  303. end;
  304.  
  305. //------------------------------------------------------------------------------
  306. // FONCTION DE CONVERSION DE LA DUREE
  307. //------------------------------------------------------------------------------
  308.  
  309. function DureeEnMinutes(s : string) : String;
  310. var
  311.      Heures, Minutes : Integer;
  312.      H,m : string;
  313. begin
  314.   Heures := 0;
  315.   Minutes := 0;
  316.   H := copy(s,1,pos('h',s)-1);
  317.   Heures := StrToInt(H,1);
  318.   Heures := Heures*60;
  319.   m := copy(s,pos('h',s)+1,length(s));
  320.   if m <> '' then
  321.   begin
  322.       Minutes := StrToInt(m,2);
  323.       Minutes := Heures+Minutes;
  324.       m := IntToStr(Minutes);
  325.       result := m;
  326.   end else
  327.   begin
  328.       H := IntToStr(Heures);
  329.       result := H;
  330.   end;
  331. end;
  332.  
  333. //------------------------------------------------------------------------------
  334. // FONCTION MOYENNE SUR DIX
  335. //------------------------------------------------------------------------------
  336.  
  337. function moyenne(Note1, Note2 : string) : String;  // Calcul la moyenne des notes
  338. var
  339.      unite1, decimale1, unite2, decimale2 : Integer;
  340. begin
  341.   if (Note1 = '--') and (Note2 = '--') then // Si pas de notes
  342.   begin
  343.     result := '';
  344.     exit;
  345.   end;
  346.   if (Note1 <> '--') then
  347.   begin
  348.     unite1 := uniteValue(Note1);
  349.     decimale1 := decimaleValue(Note1);
  350.   end else
  351.   begin
  352.     unite1 := uniteValue(Note2);
  353.     decimale1 := decimaleValue(Note2);
  354.   end;
  355.   if (Note2 <> '--') then
  356.   begin
  357.     unite2 := uniteValue(Note2);
  358.     decimale2 := decimaleValue(Note2);
  359.   end else
  360.   begin
  361.     unite2 := unite1;
  362.     decimale2 := decimale1;
  363.   end;
  364.   unite1 := unite1+unite2; // Somme des deux moyennes
  365.   decimale1 := decimale2+decimale1;
  366.   if decimale1 = 10 then
  367.   begin
  368.     decimale1 := 0;
  369.     unite1 := unite1+1;
  370.   end else if decimale1 > 10 then
  371.   begin
  372.     decimale1 := decimale1-10;
  373.     unite1 := unite1+1;
  374.   end;
  375.   result := IntToStr(unite1)+','+IntToStr(decimale1);
  376. end;
  377.  
  378. function uniteValue(Note : string) : Integer;  // retourne la valeur des chiffre avant la virgule
  379. var
  380.      unite : Integer;
  381. begin
  382.   unite := 0;
  383.   if pos('.',Note) <> 0 then
  384.     Note := copy(Note,1,pos('.',Note)-1);
  385.   unite := StrToInt(Note,1);
  386.   result := unite;
  387. end;
  388.  
  389. function decimaleValue(Note : string) : Integer;  // retourne la valeur des chiffre aprΦs la virgule
  390. var
  391.      decimale : Integer;
  392. begin
  393.   decimale := 0;
  394.   if pos('.',Note) <> 0 then
  395.   begin
  396.     Note := copy(Note,pos('.',Note)+1,length(Note));
  397.     decimale := StrToInt(Note,1);
  398.   end;
  399.   result := decimale;
  400. end;
  401.  
  402. //------------------------------------------------------------------------------
  403. // NETTOIE ANNEE
  404. //------------------------------------------------------------------------------
  405.  
  406. function nettoieAnnee(annee : String) : string;
  407. begin
  408.   if pos(' 19',annee) <> 0 then
  409.   begin
  410.     annee := copy(annee,pos(' 19',annee),length(annee));
  411.     annee := Trim(annee);
  412.   end else
  413.   if pos(' 20',annee) <> 0 then
  414.   begin
  415.     annee := copy(annee,pos(' 20',annee),length(annee));
  416.     annee := Trim(annee);
  417.   end;
  418.   result := annee;
  419. end;
  420.  
  421. //------------------------------------------------------------------------------
  422. // SUPPRIME LES ACCENTS
  423. //------------------------------------------------------------------------------
  424.  
  425. function supprimeAccents(NomFilm : String) : String;
  426. begin
  427. // les accents
  428.      NomFilm := supprimeLesAccents(NomFilm);
  429. // Pour n'avoir que le titre
  430.      delete(NomFilm, pos(' - ',NomFilm), length(NomFilm));
  431.      if (pos(', ',NomFilm) > 0) then
  432.         delete(NomFilm, 1, pos(', ',NomFilm)+1);
  433.      if (pos('(',NomFilm) > 0) then
  434.         delete(NomFilm, pos('(',NomFilm), length(NomFilm));
  435.      if (pos(':',NomFilm) > 0) then
  436.         delete(NomFilm, pos(':',NomFilm), length(NomFilm));
  437.      result := trim(NomFilm);
  438. end;
  439.  
  440. //------------------------------------------------------------------------------
  441. // COMPARE LE TITRE PASSE ET LE TITRE TROUVE
  442. //------------------------------------------------------------------------------
  443.  
  444. function compareTitle(titleAllo, title : String) : String;
  445. begin
  446.      title := supprimeAccents(trim(AnsiLowerCase(title)));
  447.      titleAllo := supprimeAccents(trim(AnsiLowerCase(titleAllo)));
  448.      if (title = titleAllo) then
  449.      begin
  450.        result := 'OK';
  451.      end else
  452.      begin
  453.        result := 'KO';
  454.      end;
  455. end;
  456.  
  457. //------------------------------------------------------------------------------
  458. // TROUVE LE BON TITRE SI LE PREMIER N'EST PAS LE BON
  459. //------------------------------------------------------------------------------
  460.  
  461. procedure trouveTitle(title : String);
  462. var
  463.    oK, couple, annee, titre, adresse : String;
  464. begin
  465.    for i:=0 to listeResultat.Count-1 do
  466.    begin
  467.      couple := listeResultat.GetString(i);
  468.      annee := copy(couple,0,pos('|',couple)-1);
  469.      delete(couple, 1, length(annee)+1);
  470.      titre := copy(couple,0,pos('|',couple)-1);
  471.      delete(couple, 1, length(titre)+1);
  472.      HTMLDecode(titre);
  473.      adresse := copy(couple,0,pos('|',couple)-1);
  474.      oK := compareTitle(title,titre);
  475.      if oK = 'OK' then
  476.      begin
  477.        recupInfo(adresse);
  478.        exit;
  479.      end;
  480.    end;
  481.    listeResultat.Free;
  482.  
  483. end;
  484.  
  485. //------------------------------------------------------------------------------
  486. // PROGRAMME PRINCIPAL
  487. //------------------------------------------------------------------------------
  488.  
  489. begin
  490.   if CheckVersion(3,5,0) then
  491.   begin
  492.     if GetOption('Mise α jour') = 0 then
  493.     begin
  494.        execMenuMAJ(VersionScript,NomScript);
  495.        exit;
  496.     end;
  497.     MovieName := recupTitreRecherche(GetOption('Recherche sur le titre'));
  498.     MovieName := conversionNR(MovieName, 'RvN');
  499.     Sleep(timeSleep*2);
  500.     if (GetOption('Fichier de log') = 0) and (premiereExecution = 0) then
  501.     begin
  502.       batch(NomScript);
  503.       AddToLog('Les films ayant ΘtΘ mis α jour sont maintenant cochΘs');
  504.     end;
  505.     if (GetOption('Type de Lancement') = 0) then
  506.     begin
  507.       if Input(NomScript+' by ScorEpioN', 'Entrez le titre du film :', MovieName) then
  508.       begin
  509.         if Pos(urlDomain, MovieName) > 0 then
  510.         begin
  511.           recupInfo(MovieName);
  512.         end else
  513.           recherche(MovieName);
  514.       end;
  515.     end else
  516.     if (GetOption('Type de Lancement') = 3) then
  517.     begin
  518.       if (premiereExecution = 0) then
  519.       begin
  520.         premiereExecution := -1;
  521.         if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = False) then
  522.            exit;
  523.       end;
  524.       MovieName := GetField(fieldURL);
  525.       if Pos(urlDomain, MovieName) > 0 then
  526.          recupInfo(MovieName);
  527.     end else
  528.     begin
  529.       if (premiereExecution = 0) then
  530.       begin
  531.           premiereExecution := -1;
  532.           if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = True) then
  533.           begin
  534.             recherche(MovieName);
  535.           end else
  536.             exit;
  537.       end else
  538.       begin
  539.           recherche(MovieName);
  540.       end;
  541.     end;
  542.   end else
  543.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  544. end.
  545.